package com.hzit.manager.client;

import com.hzit.manager.client.factory.HzitFeignFallbackFactory;
import com.hzit.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

//1. 使用fallback属性进行远程的熔断处理 (方案一)
// @FeignClient(value="hzit-user",fallback = HzitFeignFallback.class)
//2. 使用fallbackFactory属性进行远程的熔断处理 (方案二)
@FeignClient(value="hzit-user",fallbackFactory = HzitFeignFallbackFactory.class)
public interface UserClient {
	@GetMapping("/user/list")
	R list();


}
@Component
class HzitFeignFallback implements UserClient{
@Override
public R list() {
	return R.fail(HttpStatus.INTERNAL_SERVER_ERROR.value(),"被调用的服务己关闭！");
}
}
